package com.wn.ziroombackend.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wn.ziroombackend.entity.Room;
import com.wn.ziroombackend.mapper.RoomMapper;
import com.wn.ziroombackend.service.RoomService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wn.ziroombackend.vo.RoomVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wangzhijia
 * @since 2023-02-27 10:56:29
 */
@Service
public class RoomServiceImpl extends ServiceImpl<RoomMapper, Room> implements RoomService {

    @Autowired
    private RoomMapper roomMapper;

    @Override
    @Transactional
    public PageInfo<RoomVo> getRoomList(Integer num, Integer size, String quartersName, String ownerName) {

//        LambdaQueryWrapper<Room> roomLambdaQueryWrapper = new LambdaQueryWrapper<>();
//        roomLambdaQueryWrapper.eq(ownerId!=null,Room::getOwnerId,ownerId);
//        roomLambdaQueryWrapper.eq(quartersId!=null,Room::getQuartersId,quartersId);

        PageHelper.startPage(num, size);
           List<RoomVo> roomVos = roomMapper.selectRoomPage(quartersName, ownerName);

        return new PageInfo<RoomVo>(roomVos);


    }

    @Override
    public Room getInfoById(Integer id) {
        return roomMapper.selectById(id);
    }
}
